home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 03 - 1987 / 03.07 Jul 87 / bit map source / notes / drag3.p next >
Encoding:
Text File  |  1987-04-02  |  1.3 KB  |  78 lines  |  [TEXT/MPS ]

  1. program drag;
  2. {$D}
  3. USES {$LOAD pinterfaces.dump}        
  4.         MemTypes,QuickDraw,OsIntf,PasLibIntf,ToolIntf,
  5.         PackIntf,IntEnv,CursorCtl,
  6.         {$LOAD}
  7.         Drag;
  8.  
  9. const
  10.     whichpict = 128;
  11.     
  12. var
  13.     myPic : PicHandle;
  14.     myRect : Rect;
  15.     mainoldPort: GrafPtr;
  16.     inc,
  17.     x,y,xinc,yinc,
  18.     temp,
  19.     start,
  20.     finish : integer;
  21.     xyPt : point;
  22.  
  23. begin{main}
  24.     InitGraf(@thePort);
  25.     GetWMgrPort( mainoldPort );
  26.     SetPort( mainoldPort );
  27.     
  28.     ClipRect( screenBits.bounds );
  29.     myPic := PicHandle(GetResource('PICT', whichPict));
  30.     
  31.     InitCursor;
  32.     repeat until button;
  33.     repeat until not button;
  34.     
  35.     InitDrag( myPic );
  36.     GetMouse(xyPt);
  37.     xinc := xyPt.h;
  38.     yinc := xyPt.v;
  39.     y := yinc;
  40.     x := xinc;
  41. repeat
  42.         GetMouse(xyPt);
  43.         if xinc > 0 then xinc := xyPt.h else xinc := -xyPt.h;
  44.         if yinc > 0 then yinc := xyPt.v else yinc := -xyPt.v;
  45.         x := x + xinc;
  46.         y := y + yinc;
  47.         if y < screenBits.bounds.top then 
  48.         begin
  49.             y := screenBits.bounds.top;
  50.             yinc := -yinc;
  51.         end
  52.         else if y > screenBits.bounds.bottom then
  53.         begin
  54.             y := screenbits.bounds.bottom;
  55.             yinc := -yinc;
  56.         end;
  57.         if x < screenBits.bounds.left then
  58.         begin
  59.             x := screenBits.bounds.left;
  60.             xinc := -xinc;
  61.         end
  62.         else if  x > screenBits.bounds.right then
  63.         begin    
  64.             x := screenBits.bounds.right;
  65.             xinc := -xinc;
  66.         end;
  67.         SetPt( xyPt, x, y );
  68.         DragItTo( xyPt );
  69.         SystemTask;
  70.         CleanIt;
  71. until button;
  72.     
  73.     TidyUpDrag;
  74.     ShowCursor;
  75.  
  76.     IEExit(0);
  77. end.
  78.